Skip to content

Conversation

@stokkie90
Copy link

No description provided.

Signed-off-by: rick.stokkingreef <rick.stokkingreef@airalo.com>
Signed-off-by: rick.stokkingreef <rick.stokkingreef@airalo.com>
Copilot AI review requested due to automatic review settings December 15, 2025 13:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the handling of team names that contain spaces by introducing a slugify method to convert team names to GitHub-compatible team slugs. When team names have spaces, GitHub's API requires them to be converted to slugs (lowercase with hyphens replacing spaces) for lookups and API calls.

Key changes:

  • Added a slugify method that converts team names to lowercase and replaces spaces with hyphens
  • Updated comparator, add, and toParams methods to use the new slugify logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +55 to +57
slugify (name) {
return name.toLowerCase().replace(/\s+/g, '-')
}
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slugify method lacks test coverage for team names with spaces. Given that this is the core fix for handling team names with spaces, tests should verify that names like "My Team Name" are correctly converted to "my-team-name". Add test cases covering single spaces, multiple consecutive spaces, and edge cases like leading/trailing spaces.

Copilot uses AI. Check for mistakes.
}
}
slugify (name) {
return name.toLowerCase().replace(/\s+/g, '-')
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slugify implementation doesn't handle leading or trailing spaces, which would result in slugs with leading or trailing hyphens (e.g., " Team Name " becomes "-team-name-"). Additionally, it doesn't handle other special characters that GitHub may not allow in team slugs. Consider trimming the input first and potentially handling other characters that need to be converted or removed.

Suggested change
return name.toLowerCase().replace(/\s+/g, '-')
// Trim, replace whitespace with hyphens, remove disallowed chars, trim hyphens
return name
.trim()
.toLowerCase()
.replace(/\s+/g, '-') // Replace whitespace with hyphens
.replace(/[^a-z0-9-]/g, '') // Remove disallowed characters
.replace(/^-+|-+$/g, ''); // Remove leading/trailing hyphens

Copilot uses AI. Check for mistakes.
team_id: existing.id,
org: this.repo.owner,
team_slug: attrs.name,
team_slug: this.slugify(existing.name),
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The team_slug should use attrs.name instead of existing.name. The toParams method receives attrs from the config (which contains the team name as specified in the configuration) and existing from the GitHub API (which already has a slug property). Using existing.name here is inconsistent with how attrs.name is used elsewhere in this file (lines 60, 79), and it may not work correctly if the existing object structure differs from expectations. The consistent approach is to slugify the attrs.name parameter.

Suggested change
team_slug: this.slugify(existing.name),
team_slug: this.slugify(attrs.name),

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants